home *** CD-ROM | disk | FTP | other *** search
Text File | 1996-04-12 | 2.5 KB | 99 lines | [TEXT/CWIE] |
- /*
- File: LProgessIndicator.cp
-
- Contains: Abstract base class for the display of progress
- to the user.
-
- Insulates a calling entity from the the details of the
- method used to display the progress to the user. IOW,
- isolation of the user interface from low-level code.
-
- Generally, you'll pass an LProgressIndicator subclass to
- some piece of code which only knows about this abstract
- class, and it will call the CompletedThisMuch() functions
- to indicate the total amount of the task completed. This
- removes the burden of displaying progress to the user from
- the shoulders of the independent code module writer, and
- allows you to implement consistent feedback throughout
- your application using your preferred interface.
-
- Uses PowerPlant naming conventions, but doesn't require
- PowerPlant.
-
- Version: 2.0
-
- Author: Chris K. Thomas, ckt@best.com
-
- Copyright: ©1995 Chris K. Thomas. All Rights Reserved.
- */
-
- // * includes
- #include "LProgressIndicator.h"
-
- // * default constructor
- LProgressIndicator::
- LProgressIndicator()
- {
- mTaskType = task_Indeterminate;
- mMinValue = 0;
- mMaxValue = 100;
- mCurValue = 0;
- }
-
- // * immediate constructor
- LProgressIndicator::
- LProgressIndicator(ETaskType inTaskType, SInt32 inMin, SInt32 inMax, SInt32 inStartMax)
- {
- mTaskType = inTaskType;
- mMinValue = inMin;
- mMaxValue = inMax;
- mCurValue = inStartMax;
- }
-
- LProgressIndicator::~LProgressIndicator()
- {
-
- }
-
- // * Making progress absolutely
- void LProgressIndicator::CompletedThisMuch(SInt32 inThisMuch)
- {
- //
- // threshold - if you don’t want a DebugStr when/if you go
- // over the MaxValue or under the MinValue, comment out the
- // SignalPStr lines. If the task is measured, we don’t need
- // to threshold. SignalPStr is a no-op when PowerPlant
- // debugging is off.
- //
- if(GetTaskType() == task_Measured)
- {
- if(inThisMuch > GetMaxValue())
- {
- SignalPStr_("\pLProgressIndicator: I've been passed a current value greater than the maximum value.");
- return;
- }
- else if(inThisMuch < GetMinValue())
- {
- SignalPStr_("\pLProgressIndicator: I've been passed a current value less than the minimum value.");
- return;
- }
- }
-
- mCurValue = inThisMuch;
- ValueChanged();
- }
-
- // * Making progress incrementally
- void LProgressIndicator::CompletedThisMuchMore(SInt32 inThisMuchMore)
- {
- CompletedThisMuch(mCurValue + inThisMuchMore);
- }
-
- // * derived classes override this usually
- void LProgressIndicator::ValueChanged()
- {
- // * this could be pure virtual...
- }
-
-
-